﻿<?php
$bdd = new PDO('mysql:host=localhost;dbname=brin_de_soleil_chris', 'root', '');
$bdd->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );

// Insertion paiement inscription
$req = $bdd->prepare('INSERT INTO inscription_paiement(total_sejour, fact_groupe, cotisation, montant_transp, assurance, remise, solde, solde_payer)
VALUES(:totalsejour, :factgroupe, :cotisation, :montant, :assurance, :remise, :solde, :soldepayer)');
$req->execute(array(
	'totalsejour' => $_POST['totalsejour'],
	'factgroupe' => isset($_POST['factgroupe'])?1:0,
	'cotisation' => $_POST['cotisation'],
	'montant' => $_POST['montant'],
	'assurance' => $_POST['assurance'],
	'remise' => $_POST['remise'],
	'solde' => $_POST['solde'],
	'soldepayer' => $_POST['soldepayer'],
	));
$id_inscription_paiement = $bdd->lastInsertId();

// Insertion d'une nouvelle inscription
$req = $bdd->prepare('INSERT INTO inscription(date_creation, id_identite, num_compte_comptable, commentaire, sejour_demande1, date_option, intitule_sejour1, semaine1, semaine2, semaine3, date_debut, lieu_depart_premier, surplacedebut, num_vehicule_debut, presence_resp_debut, nom_resp_debut, tel_resp_debut, medic_transport_debut, date_fin, lieu_depart_second, surplacefin, num_vehicule_fin, pres_resp_fin, nom_resp_fin, tel_resp_fin, medic_fin, date_depart, lieu_depart, date_retour, lieu_retour, id_inscription_paiement)
VALUES(:date_creation, :participant, :numcompte, :commentaire, :demande, :option, :intitule, :semaine1, :semaine2, :semaine3, :datedebut, :lieudebut, :surplacedebut, :numvehiculedebut, :presrespdebut, :nomrespdebut, :telrespdebut, :medicamentdebut, :datefin, :lieufin, :surplacefin, :numvehiculefin, :presrespdebut, :nomrespfin, :telrespfin, :medicamentfin, :datedepart, :lieudepart, :dateretour, :lieuretour, :id_inscription_paiement)');
$req->execute(array(
		'date_creation' => $_POST['creation'],
		'id_identite' => select_id_identite($bdd, $_POST['participant'], '', '', '', '', ''),	// A voir, vérifier si ça pose un pb de ne pas mettre tous les arguments.
		'numcompte' => $_POST['numcompte'],
		'commentaire' => $_POST['commentaire'],
		'demande' => $_POST['demande'],
		'option' => $_POST['option'],
		'intitule' => $_POST['intitule'],
		'semaine1' => isset($_POST['semaine1'])?1:0,
		'semaine2' => isset($_POST['semaine2'])?1:0,
		'semaine3' => isset($_POST['semaine3'])?1:0,
		'datedebut' => $_POST['datedebut'],
		'lieudebut' => $_POST['lieudebut'],
		'surplacedebut' => isset($_POST['surplacedebut'])?1:0,
		'numvehiculedebut' => $_POST['numvehiculedebut'],
		'presrespdebut' => isset($_POST['presrespdebut'])?1:0,
		'nomrespdebut' => $_POST['nomrespdebut'],
		'telrespdebut' => $_POST['telrespdebut'],
		'medicamentdebut' => isset($_POST['medicamentdebut'])?1:0,
		'datefin' => $_POST['datefin'],
		'lieufin' => $_POST['lieufin'],
		'surplacefin' => isset($_POST['surplacefin'])?1:0,
		'numvehiculefin' => $_POST['numvehiculefin'],
		'presrespfin' => isset($_POST['presrespfin'])?1:0,
		'nomrespfin' => $_POST['nomrespfin'],
		'telrespfin' => $_POST['telrespfin'],
		'medicamentfin' => isset($_POST['medicamentfin'])?1:0,
		'datedepart' => $_POST['datedepart'],
		'lieudepart' => $_POST['lieudepart'], 
		'dateretour' => $_POST['dateretour'],
		'lieuretour' => $_POST['lieuretour'],
		'id_inscription_paiement' => $id_inscription_paiement
	));


	
$req = $bdd->prepare('INSERT INTO acompte(acompte1, verse_le1, mode_regl1, acompte2, verse_le2, mode_regl2, acompte3, verse_le3, mode_regl3, acompte4, verse_le4, mode_regl4)
VALUES(:acompte1, :verse1, :reglement1, :acompte2, :verse2, :reglement2, :acompte3, :verse3, :reglement3, :acompte4, :verse4, :reglement4)');
$req->execute(array(
	'acompte1' => $_POST['acompte1'],
	'verse1' => $_POST['verse1'],
	'reglement1' => $_POST['reglement1'],
	'acompte2' => $_POST['acompte2'],
	'verse2' => $_POST['verse2'],
	'reglement2' => $_POST['reglement2'],
	'acompte3' => $_POST['acompte3'],
	'verse3' => $_POST['verse3'],
	'reglement3' => $_POST['reglement3'],
	'acompte4' => $_POST['acompte4'],
	'verse4' => $_POST['verse4'],
	'reglement4' => $_POST['reglement4'],
	));

$req = $bdd->prepare('INSERT INTO inscription_fraismedic(bon_resa, inscr_prise_par, fact_convention, argent_poche, depart_proj_av, montant, crobs_avent, date_envoi, reglement_ok, date_regl, mode_regl_argent, dossier_envoi, dossier_recu, montant_fraismedic, date_frais, dossier_complet, reglement_frais, date_regl_frais, mode_regl_frais, description, type_soin, annulation, motif)
VALUES(:bonresa, :inscrpar, :factconv, :argentpoche, :departproj, :montant, :crobsavent, :dateenvoi, :reglementeffect, :datereglement, :reglement_argent, :dossierenvoye, :dossierrecu, :montantfrais, :dateenvoi_frais, :dossiercomplet, :reglementeffectfrais, :datereglementfrais, :reglementfrais, :description, :type, :dateannulation, :motif)');
$req->execute(array(
	'bonresa' => isset($_POST['bonresa'])?1:0,
	'inscrpar' => $_POST['inscrpar'],
	'factconv' => isset($_POST['factconv'])?1:0,
	'argentpoche' => isset($_POST['argentpoche'])?1:0,
	'departproj' => isset($_POST['departproj'])?1:0,
	'montant' => $_POST['montant'],
	'crobsavent' => isset($_POST['crobsavent'])?1:0,
	'dateenvoi' => $_POST['dateenvoi'],
	'reglementeffect' => isset($_POST['reglementeffect'])?1:0,
	'datereglement' => $_POST['datereglement'],
	'reglement_argent' => $_POST['reglement_argent'],
	'dossierenvoye' => isset($_POST['dossierenvoye'])?1:0,
	'dossierrecu' => isset($_POST['dossierrecu'])?1:0,
	'montantfrais' => $_POST['montantfrais'],
	'dateenvoi_frais' => $_POST['dateenvoi_frais'],
	'dossiercomplet' => isset($_POST['dossiercomplet'])?1:0,
	'reglementeffectfrais' => isset($_POST['reglementeffectfrais'])?1:0,
	'datereglementfrais' => $_POST['datereglementfrais'],
	'reglementfrais' => $_POST['reglementfrais'],
	'description' => $_POST['description'],
	'type' => $_POST['type'],
	'dateannulation' => $_POST['dateannulation'],
	'motif' => $_POST['motif'],
	));

$req = $bdd->prepare('INSERT INTO inscription_infomedic(autonomie, cardio, suicidaire, signature_auto, suit_traitement_medic, alcool, sortie, soin, baignade, fugue, prend_seul_traitement, rester_seul, epilepsie, fiche_suivi, photo, enuresie, contraception, num_urgence, encopresie, medecin, hospitalisation, asthme, ordonnance, changement, agressif, signature_fiche, couple, conjoint)
VALUES(:autonomie, :cardiopathie, :suicidaire, :signature, :suit_traitement, :alcool, :sortie, :soins_infirm, :baignade, :fugue, :prend_seul_traitement, :rester_seul, :epilepsie, :fiche_suivi, :photos, :enuresie, :contraception, :num_urgence, :encopresie, :medecin, :hospitalisation, :asthme, :ordonnance, :changement, :agressif, :signature_fiche, :couple, :conjoint)');
$req->execute(array(
	'autonomie' => isset($_POST['autonomie'])?1:0,
	'cardiopathie' => isset($_POST['cardiopathie'])?1:0,
	'suicidaire' => isset($_POST['suicidaire'])?1:0,
	'signature' => isset($_POST['signature'])?1:0,
	'suit_traitement' => isset($_POST['suit_traitement'])?1:0,	
	'alcool' => isset($_POST['alcool'])?1:0,
	'sortie' => isset($_POST['sortie'])?1:0,
	'soins_infirm' => isset($_POST['soins_infirm'])?1:0,
	'baignade' => isset($_POST['baignade'])?1:0,
	'fugue' => isset($_POST['baignade'])?1:0,
	'prend_seul_traitement' => isset($_POST['prend_seul_traitement'])?1:0,
	'rester_seul' => isset($_POST['rester_seul'])?1:0,
	'epilepsie' => isset($_POST['epilepsie'])?1:0,
	'fiche_suivi' => isset($_POST['fiche_suivi'])?1:0,
	'photos' => isset($_POST['photos'])?1:0,
	'enuresie' => isset($_POST['enuresie'])?1:0,
	'contraception' => isset($_POST['contraception'])?1:0,
	'num_urgence' => isset($_POST['num_urgence'])?1:0,
	'encopresie' => isset($_POST['encopresie'])?1:0,
	'medecin' => isset($_POST['medecin'])?1:0,
	'hospitalisation' => isset($_POST['hospitalisation'])?1:0,
	'asthme' => isset($_POST['asthme'])?1:0,
	'ordonnance' => isset($_POST['ordonnance'])?1:0,
	'changement' => isset($_POST['changement'])?1:0,
	'agressif' => isset($_POST['agressif'])?1:0,
	'signature_fiche' => isset($_POST['signature_fiche'])?1:0,
	'couple' => isset($_POST['couple'])?1:0,
	'conjoint' => $_POST['conjoint'],
	));
	
?>